Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor DMLQueryBuilder #746

Merged
merged 26 commits into from
Nov 1, 2023
Merged

Conversation

Tigrov
Copy link
Member

@Tigrov Tigrov commented Aug 19, 2023

Refactoring with:

  • Fix bug when unique index is not at the first position of inserted values in upsert() test
  • Typecast values if column names with table name and brackets ['{{%type}}.[[int_col]]', '[[float_col]]'] wrongBehavior
  • Typecast values in batchInsert() if values with string keys Batchinsert and associative arrays #61 (point 2)
  • Add info: methods batchInsert(), insert(), update(), upsert() allow columns of the passed table only Different tables in columns #744

Related PRs

Q A
Is bugfix? ✔️
New feature?
Breaks BC?
Fixed issues test, #61 (point 2), #744, wrongBehavior

@what-the-diff
Copy link

what-the-diff bot commented Aug 19, 2023

PR Summary

  • Improvements in CHANGELOG.md:
    Made several changes to enhance and fix issues with the AbstractDMLQueryBuilder class. These include general refactoring, fixing a specific issue when a unique index isn't positioned first among inserted values, and better typecasting of values in cases of column names with table names and brackets, or values with string keys. Documentation for batchInsert() and update() methods was also improved.

  • Addition in psalm.xml:
    Suppressed a MixedAssignment issue. This means we have suppressed a warning about mixing different data types, improving the integrity of the codebase.

  • Updates in CommandInterface.php:
    Added type hinting (helpful information about what kind of data a function should be receiving) for the batchInsert() and update() methods. This helps ensure the correct data types are being used in the code.

  • Changes in AbstractQueryBuilder.php and others:
    Removed usage of the Generator class and added better type hinting, leading to improved code quality and maintainability. A generator is a type of function that allows you to declare a function that behaves like an iterator.

  • Changes in QueryBuilderTest.php, AbstractQueryBuilderTest.php and CommandProvider.php:
    Improved the testBatchInsert() method by changing and updating its type hinting. This helps ensure that it receives the correct type of data.

  • Additions in QueryBuilderProvider.php and AbstractQueryBuilderTest.php:
    New test cases have been added for column table names without checking. Tests are critical in ensuring that our code is functioning as expected.

@codecov
Copy link

codecov bot commented Aug 19, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (4f1dbb9) 99.21% compared to head (fda606c) 99.05%.

Additional details and impacted files
@@             Coverage Diff              @@
##             master     #746      +/-   ##
============================================
- Coverage     99.21%   99.05%   -0.17%     
+ Complexity     1272     1260      -12     
============================================
  Files            67       67              
  Lines          3072     3059      -13     
============================================
- Hits           3048     3030      -18     
- Misses           24       29       +5     
Files Coverage Δ
src/Command/CommandInterface.php 0.00% <ø> (ø)
src/QueryBuilder/AbstractDMLQueryBuilder.php 97.45% <100.00%> (-2.55%) ⬇️
src/QueryBuilder/AbstractQueryBuilder.php 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Tigrov
Copy link
Member Author

Tigrov commented Aug 21, 2023

Remove following methods from AbstractDMLQueryBuilder?

  • AbstractDMLQueryBuilder::insertWithReturningPks() - the specific implementation has its own thrown exception;
  • AbstractDMLQueryBuilder::resetSequence() - supported by all implemented DBMS;
  • AbstractDMLQueryBuilder::upsert() - supported by all implemented DBMS.

They all throw the exceprion throw new NotSupportedException(__METHOD__ . '() is not supported by this DBMS.');

Or are they needed for future implementations?

src/QueryBuilder/AbstractDMLQueryBuilder.php Show resolved Hide resolved
src/QueryBuilder/AbstractDMLQueryBuilder.php Outdated Show resolved Hide resolved
src/QueryBuilder/AbstractDMLQueryBuilder.php Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
@Tigrov Tigrov merged commit 39872b1 into yiisoft:master Nov 1, 2023
83 of 85 checks passed
@Tigrov Tigrov deleted the refactor_dml_query_builder branch November 1, 2023 03:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants